// 2025/2/24
// https://www.lanqiao.cn/problems/20035/learning/?page=1&first_category_id=1
// 消灭卡片

#include <iostream>
using namespace std;
int main()
{
  // 请在此输入您的代码
  int t = 0, n = 0; cin >> t;
  for(int i = 0; i < t; i++)
  {
    cin >> n;
    int ans = -1;
    for(int j = 0; 3 * j <= n; j++)
    {
      int left = n - 3 * j;
      if(left % 5 == 0)
      {
        ans = j + left / 5;
        break;
      }
    }
    cout << ans << endl;
  }
  return 0;
}